package day21_28.day23;

import java.util.Scanner;

public class Main02 {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        String str1 = scn.next();
        String str2 = scn.next();
        int[][] arr = new int[str1.length() + 1][str2.length() + 1];
        for (int i = 1 ; i < arr.length; i++) {
            arr[i][0] = i;
        }
        for (int i = 1; i < arr[0].length; i++) {
            arr[0][i] = i;
        }
        for (int i = 1; i <  arr.length; i++) {
            for (int j = 1; j < arr[i].length; j++) {
                if (str1.charAt(i - 1) == str2.charAt(j - 1)){
                    arr[i][j] = arr[i - 1][j - 1];
                }else {
                    arr[i][j] = Math.min(arr[i - 1][j - 1] , Math.min(arr[i - 1][j] , arr[i][j - 1])) + 1;
                }
            }
        }
        System.out.println(arr[str1.length() ][str2.length() ]);
    }
}
